package com.darren.befriend.fragments;

import java.util.ArrayList;

import com.darren.befriend.BaseActivity;
import com.darren.befriend.HomeActivity;
import com.darren.befriend.R;
import com.darren.befriend.UserSettingInitialActivity;
import com.darren.befriend.constants.Constant;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.View;

public class InterestFragment extends HobbyBaseFragment {

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		interestTextArr = getResources().getStringArray(
				R.array.interest_text_arr);
		mInterestResIds = new int[] { R.drawable.int0, R.drawable.int1,
				R.drawable.int2, R.drawable.int3, R.drawable.int4,
				R.drawable.int5, R.drawable.int6, R.drawable.int7,
				R.drawable.int8, R.drawable.int9, R.drawable.int10,
				R.drawable.int11, R.drawable.int12, R.drawable.int13,
				R.drawable.int14, R.drawable.int15, R.drawable.int16,
				R.drawable.int17, R.drawable.int18, R.drawable.int19,
				R.drawable.int20, R.drawable.int21, R.drawable.int22,
				R.drawable.int23, R.drawable.int24, R.drawable.int25,
				R.drawable.int26, R.drawable.int27, R.drawable.int28,
				R.drawable.int29, R.drawable.int30, R.drawable.int31,
				R.drawable.int32, R.drawable.int33, R.drawable.int34,
				R.drawable.int35, R.drawable.int36, R.drawable.int37,
				R.drawable.int38, R.drawable.int39 };
		if (getArguments() != null) {
			MODE_VALUE = getArguments().getInt(MODE, 0);
		}
	}

	@SuppressWarnings("unchecked")
	@Override
	public void onActivityCreated(Bundle savedInstanceState) {

		mCurrentUser = ((BaseActivity) getActivity()).getCurrentUser();
		if (mCurrentUser != null) {
			mSelected = (ArrayList<Boolean>) mCurrentUser.get("INTEREST");
		}

		super.onActivityCreated(savedInstanceState);
		mTitle = getString(R.string.interest);
		if (getActivity() instanceof UserSettingInitialActivity) {
			((UserSettingInitialActivity) getActivity())
					.setActivityTitle(mTitle);
			if (MODE_VALUE == FIRST_MODE) {
				((UserSettingInitialActivity) getActivity())
						.setNavigationImage(Integer.MAX_VALUE,
								R.drawable.item_sport);
			} else if (MODE_VALUE == SECOND_MODE) {
				((UserSettingInitialActivity) getActivity())
						.setNavigationImage(R.drawable.item_back,
								Integer.MAX_VALUE);
			}
		} else if (getActivity() instanceof HomeActivity) {
			((HomeActivity) getActivity()).showRightButtonImg(false);
			((HomeActivity) getActivity()).setLeftImage(R.drawable.item_back);
			((HomeActivity) getActivity()).setActivityTitle(mTitle);
		}
	}

	public static Fragment create(int mode) {
		InterestFragment fragment = new InterestFragment();
		Bundle bundle = new Bundle();
		bundle.putInt(MODE, mode);
		fragment.setArguments(bundle);
		return fragment;
	}

	@Override
	public void onClick(View v) {
		HOBBY_TYPE = Constant.INTEREST;
		super.onClick(v);
	}

}
